from fbri.private.sql.query import execute

database = "fbri_prod_private"
table = "erc_condor_url_attributes_dp_final"

sql = f"""
SELECT a.false_news_usr_feedback, a.clean_url,
b.views, b.clicks, b.shares, b.likes, 
b.age_bracket, b.gender, b.political_page_affinity, b.year_month
FROM {database}.{'ERC_CONDOR_URL_BREAKDOWNS_DP_CLEAN_PARTITIONED'} b
JOIN {database}.{'ERC_CONDOR_URL_ATTRIBUTES_DP_FINAL'} a
ON (
 a.url_rid = b.url_rid
 AND a.public_shares_top_country = 'US'
 AND b.c = 'US'
 AND a.false_news_usr_feedback > 1
 AND b.year_month = '2018-10'
 AND b.political_page_affinity = '2'

)
WHERE a.public_shares_top_country = 'US'
"""
result = execute(sql, "results.tsv")
